package cn.ad.model;

/**
 * Created by zooy on 16-12-28.
 */
public class ResultModel {

    /**
     * 返回code码
     * 200 -- 正常
     * 401 -- 没有权限
     * 500 -- 服务器错误
     */
    private int code;

    /**
     * 存放数据
     */
    private Object data;

    /**
     * 存放消息
     */
    private String message;

    public ResultModel() {
        this.code = 200;
    }

    public ResultModel(Object data) {
        this.code = 200;
        this.data = data;
    }

    public void success(Object data) {
        this.code = 200;
        this.data = data;
    }

    public ResultModel failed(String message) {
        this.code = 500;
        this.message = message;
        return this;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public int getCode() {
        return code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
